#include <cstdio>
#include <chrono>
#include <thread>

#include "simple/graphical/initializer.h"
#include "simple/graphical/software_window.h"

using namespace std::chrono_literals;
using namespace simple::graphical;
using namespace simple::geom;
using namespace simple::graphical::color_literals;

int main(int argc, char *argv[]) try
{
    software_window window("ANDROID", int2::zero());
	const auto& surface = window.surface();

	std::puts("ello there can I log?");

    auto frame_time = 16ms;
	auto end_of_time = std::chrono::high_resolution_clock::now() + 3s;
	for
	(
		auto next_frame_time = std::chrono::high_resolution_clock::now();
		next_frame_time <= end_of_time;
		next_frame_time += frame_time,
		std::this_thread::sleep_until(next_frame_time)
	)
	{
		fill(surface, surface.format().color(0xff00ff_rgb));
		window.update();
	}

	return 0;
}
catch(...)
{
	if(errno)
		std::perror("ERROR");

	const char* sdl_error = SDL_GetError();
	if(*sdl_error)
		std::puts(sdl_error);

	throw;
}
